package com.sgcc.sx.pmos.e_sx_mall.adapter;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sgcc.sx.pmos.common.bean.PowMonth;
import com.sgcc.pmos.nativesdk.R;

public class PowerSetTotalAdapter extends BaseQuickAdapter<PowMonth, BaseViewHolder> {
    private String year;
    public PowerSetTotalAdapter() {
        super(R.layout.item_powerset_total);
    }

    public void setYear(String year) {
        this.year=year;
    }
    public interface OnItemClickListener {
        //条目点击
        void OnItemsClickListener(int position, String s);
    }

    private OnItemClickListener mOnItemClickListener;

    public void setItemClickListener(OnItemClickListener onItemClickListener) {
        this.mOnItemClickListener = onItemClickListener;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, PowMonth s) {

        baseViewHolder.setText(R.id.month_txt,year+"年"+s.getMonthDate()+"月");
        ((EditText)baseViewHolder.getView(R.id.power_total_edit)).addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                s.setREnergy(Integer.valueOf(editable.toString())+"");
            }
        });
//        baseViewHolder.getView(R.id.rl_store).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                if (mOnItemClickListener != null) {
//                    mOnItemClickListener.OnItemsClickListener(getItemPosition(s), s);
//                }
//            }
//        });
    }
}
